# Select by length

This example selector selects which examples to use based on length. This is useful when you are worried about constructing a prompt that will go over the length of the context window. For longer inputs, it will select fewer examples to include, while for shorter inputs it will select more.

import CodeBlock from "@theme/CodeBlock";
import ExampleLength from "@examples/prompts/length_based_example_selector.ts";

<CodeBlock language="typescript">{ExampleLength}</CodeBlock>
